package com.zj.fx.service.info;

import java.util.List;
import java.util.Arrays;

import com.zj.fx.mapper.info.InfoTargetStepMapper;
import com.zj.fx.model.info.InfoTargetStep;
import com.zj.fx.model.info.InfoTargetStepExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import cn.hutool.core.util.StrUtil;
import com.zj.fx.common.base.BaseService;
import com.zj.fx.common.support.ConvertUtil;
import com.zj.fx.model.custom.Tablepar;
import com.zj.fx.util.SnowflakeIdWorker;
import com.zj.fx.util.StringUtils;

/**
 * 管理提升目标操作步骤明细表 InfoTargetStepService
 *
 * @author SQL_自动生成
 * @Title: InfoTargetStepService.java 
 * @Package com.zj.fx.service 
 * @email ${email}
 * @date 2023-07-07 09:00:13  
 **/
@Service
public class InfoTargetStepService implements BaseService<InfoTargetStep, InfoTargetStepExample> {
    @Autowired
    private InfoTargetStepMapper infoTargetStepMapper;


    /**
     * 分页查询
     *
     * @param
     * @param
     * @return
     */
    public PageInfo<InfoTargetStep> list(Tablepar tablepar, InfoTargetStep infoTargetStep) {
        InfoTargetStepExample testExample = new InfoTargetStepExample();
        //搜索
        if (StrUtil.isNotEmpty(tablepar.getSearchText())) {//小窗体
            testExample.createCriteria().andLikeQuery2(tablepar.getSearchText());
        } else {//大搜索
            testExample.createCriteria().andLikeQuery(infoTargetStep);
        }
        //表格排序
        if(StrUtil.isNotEmpty(tablepar.getOrderByColumn())) {
        	testExample.setOrderByClause(StringUtils.toUnderScoreCase(tablepar.getOrderByColumn()) +" "+tablepar.getIsAsc());
        }else{
        	testExample.setOrderByClause("ordernum+0 ASC");
        }
        PageHelper.startPage(tablepar.getPage(), tablepar.getLimit());
        List<InfoTargetStep> list = infoTargetStepMapper.selectByExample(testExample);
        PageInfo<InfoTargetStep> pageInfo = new PageInfo<InfoTargetStep>(list);
        return pageInfo;
    }

    @Override
    public int deleteByPrimaryKey(String ids) {

        List<String> lista = ConvertUtil.toListStrArray(ids);
        InfoTargetStepExample example = new InfoTargetStepExample();
        example.createCriteria().andIdIn(lista);
        return infoTargetStepMapper.deleteByExample(example);


    }


    @Override
    public InfoTargetStep selectByPrimaryKey(String id) {

        return infoTargetStepMapper.selectByPrimaryKey(id);

    }


    @Override
    public int updateByPrimaryKeySelective(InfoTargetStep record) {
        return infoTargetStepMapper.updateByPrimaryKeySelective(record);
    }


    /**
     * 添加
     */
    @Override
    public int insertSelective(InfoTargetStep record) {

        //添加雪花主键id
        record.setId(SnowflakeIdWorker.getUUID());


        return infoTargetStepMapper.insertSelective(record);
    }


    @Override
    public int updateByExampleSelective(InfoTargetStep record, InfoTargetStepExample example) {

        return infoTargetStepMapper.updateByExampleSelective(record, example);
    }


    @Override
    public int updateByExample(InfoTargetStep record, InfoTargetStepExample example) {

        return infoTargetStepMapper.updateByExample(record, example);
    }

    @Override
    public List<InfoTargetStep> selectByExample(InfoTargetStepExample example) {

        return infoTargetStepMapper.selectByExample(example);
    }


    @Override
    public long countByExample(InfoTargetStepExample example) {

        return infoTargetStepMapper.countByExample(example);
    }


    @Override
    public int deleteByExample(InfoTargetStepExample example) {

        return infoTargetStepMapper.deleteByExample(example);
    }


}
